<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>设置权限</title>
    <script type="text/javascript" src="${path}/js/public/tree.js"></script>
    <script type="text/javascript">
    
    	var zTreeObj = null;
    	
    	$().ready(function(){
    		
    		zTreeObj = createSimpleTree({url:"${path}/tree?method=getPrivilegeTree&roleId=${param.roleId}",zTreeId:"tree",chkStyle:"checkbox"});
    	});
    	
    	function doSave()
    	{
    		if(zTreeObj != null)
    		{
    			var checkedNodes = zTreeObj.getCheckedNodes(true);
    			var privilegeIds = new Array("");
    			
    			for(var i = 0 ; i < checkedNodes.length ; ++i)
    			{
    				privilegeIds.push(checkedNodes[i].id + "");
    			}
    			ajax.remoteCall("com.system.dao.RoleDao:setPrivilege",[privilegeIds,"${param.roleId}"],function(reply){
        			var result = reply.getResult();
        			alert(result.value);
        			if(result.type == "success")
        			{
        				var dlg = Dialog.getInstance("view");
        	    		var parent = dlg.getParam('window');
        	    		dlg.close();
        			}
        		});
    		}
    	}
    </script>
  </head>
  <body>

	<div style="margin-left: 30px;margin-top: 15px">
 		<ul id="tree" class="ztree" style="width:100%;overflow:auto;height:100%"></ul>
 	</div>
  </body>
</html>
